/**
 * 
 */
package com.barisergun.memcached;

import java.util.*;

/**
 * @author barise
 * @date Dec 20, 2010
 * 
 */

public class TestVariables {

	public static final String MEMCACHE_SERVER_LOCAL_CACHE_SIZE_ARGUMENT = "-m 512";

	public static final Integer MEMCACHE_SERVER_ADDRESS_PORT_ROOT = 1121;

	public static final Integer NUMBER_OF_LOCAL_CACHE_SERVERS = 8;

	public static final String SINGLE_MSISDN_FOR_TEST = "915309999999";

	public static final int TTL_IN_SECONDS_SHORT = 2;	

	public static final double SAMPLE_X_COORD = 10.00D;

	public static final double SAMPLE_Y_COORD = 20.00D;

	public static final String REPORT_INFO_STRING = "Duration of %s for %s %d entries in %d msec with %d local cache servers. Average tps is %f .";

	public static final String DISTRIBUTED_REPORT_INFO_STRING = "Duration of %s for %s %d entries in %d msec with %d cache servers. Average tps is %f .";

	public static final String EXCEPTION_STRING = "Exception in index %d";

	public static final String INSERT_STRING = "inserting";

	public static final String READING_STRING = "reading";

	public static final String MEMCACHED_SYNCH_TEST_INFO_STRING = "Memcached Synchronous Tests";

	public static final String MEMCACHED_ASYNCH_TEST_INFO_STRING = "Memcached Asynchronous Tests";

	public static final String CONCURRENT_HASHMAP_TEST_INFO_STRING = "ConcurrentHashMap Tests";

	public static final String FAILED_TO_INSERT_STRING = "Failed insert in data for msisdn %s.";

	public static final String REPORT_CONCURRENT_CACHES_TERMINATED_STRING = "Duration for verifying all the sets are cached  concurrently for %d entries in %d msec.";

	public static final String PROCESS_STRING_FORMAT = "memcached;%s;%s;%s";

	public static final String DELIMETER_STRING = ";";

	public static final String MEMCACHE_SERVER_LOCAL_ADDRESS = "127.0.0.1";

	// Privates
	private static String DISTRIBUTED_SERVERS_LIST_STRING = "";

	private static Integer ENTRY_COUNT = 5000;

	private static Integer GET_TIMEOUT_SECONDS = 1;
	
	private static int TTL_IN_SECONDS_LONG = 360;

	public static String getDistributedServers() {
		return DISTRIBUTED_SERVERS_LIST_STRING;
	}

	public static Integer getEntryCount() {
		return ENTRY_COUNT;
	}

	public static Integer getGetTimeout() {
		return GET_TIMEOUT_SECONDS;
	}	

	public static int getTtlInSeconds() {
		return TTL_IN_SECONDS_LONG;
	}

	public static void processSystemProperties() {

		Properties sysProps = System.getProperties();

		String entryCountString = sysProps.getProperty("entry.count");

		String getTimeoutString = sysProps.getProperty("get.timeout");
		
		String getTtlString = sysProps.getProperty("ttl");

		DISTRIBUTED_SERVERS_LIST_STRING = sysProps
				.getProperty("distributed.servers");

		System.out.println(entryCountString);

		if (entryCountString != null) {

			Integer entryCountAsInt = Integer.parseInt(entryCountString);

			if (entryCountAsInt != null) {

				ENTRY_COUNT = entryCountAsInt;
			}

		}

		if (getTimeoutString != null) {

			Integer getTimeoutAsInt = Integer.parseInt(getTimeoutString);

			if (getTimeoutAsInt != null) {

				GET_TIMEOUT_SECONDS = getTimeoutAsInt;
			}
		}
		
		if (getTtlString != null) {

			Integer getTtlAsInt = Integer.parseInt(getTtlString);

			if (getTtlAsInt != null) {

				TTL_IN_SECONDS_LONG = getTtlAsInt;
			}
		}

	}

}
